# Maintainer: Segfault <awarnecke002@hotmail.com>
pkgname=linux-htc-flounder
pkgver=6.0.0
pkgrel=4
pkgdesc="Google Nexus 9 kernel fork"
arch="aarch64"
_carch="arm64"
_flavor="htc-flounder"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native
	pmb:kconfigcheck-nftables pmb:kconfigcheck-zram
	pmb:kconfigcheck-containers pmb:kconfigcheck-waydroid"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev
	     devicepkg-dev bison flex openssl-dev xz findutils gzip"

# Source
_repository="linux"
_commit="1af7ece0542ef888433623a572ed8e19ca5e956a"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/TuxThePenguin0/$_repository/archive/$_commit.tar.gz
	$_config
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"

prepare() {
	default_prepare
	REPLACE_GCCH=0 \
		. downstreamkernel_prepare
}

build() {
	unset LDFLAGS

	# V=1: workaround for pma#1990
	make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS" V=1
}

package() {
	downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor" "$_outdir"

	make modules_install dtbs_install \
		O="$_outdir" ARCH="$_carch" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_DTBS_PATH="$pkgdir/boot/dtbs"

	# Flounder requires a gzip compressed kernel
	gzip "$pkgdir"/boot/vmlinuz
	mv "$pkgdir"/boot/vmlinuz.gz "$pkgdir"/boot/vmlinuz
}

sha512sums="
ee712d770cc863a6acff52ee32c5009657480864fcd748f0ccc7afb9edba912d727e56bd1d484bd391c5f3d0fed0d063ec8fca36af80c88572bcf85a6f00522e  linux-htc-flounder-1af7ece0542ef888433623a572ed8e19ca5e956a.tar.gz
c34e15446700e58c0c8c60d4fa26fa469c7fa6310d36d92ce8443d506a6b2754f341ccd8864f0b9485da1e8c428bc28bcbbeec7a64efc03dde5b4284a308c560  config-htc-flounder.aarch64
"
